﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CollegeWebsite.Areas.Administrator.Models;
namespace CollegeWebsite.Areas.Administrator.Controllers
{
    public class FeedBackController : Controller
    {
        //
        // GET: /Administrator/FeedBack/
        CollegeWebsiteDataContext _dataContext = new CollegeWebsiteDataContext();
        public ActionResult Index()
        {
            List<FeedBack> feed = _dataContext.FeedBacks.Select(f => f).ToList();
            return View(feed);
        }

        //
        // GET: /Administrator/FeedBack/Details/5

        public ActionResult Details(int id)
        {
            FeedBack feed = _dataContext.FeedBacks.Select(f => f).Single(f => f.FeedBackId == id);
            return View(feed);
        }

        //
        // GET: /Administrator/FeedBack/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Administrator/FeedBack/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /Administrator/FeedBack/Edit/5
 
        public ActionResult Edit(int id)
        {
            
            return View();
        }

        //
        // POST: /Administrator/FeedBack/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Administrator/FeedBack/Delete/5
 
        public ActionResult Delete(int id)
        {
            FeedBack feed = _dataContext.FeedBacks.Select(f => f).Single(f => f.FeedBackId == id);
            return View(feed);
        }

        //
        // POST: /Administrator/FeedBack/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                FeedBack feed = _dataContext.FeedBacks.Select(f => f).Single(f => f.FeedBackId == id);
                _dataContext.FeedBacks.DeleteOnSubmit(feed);
                _dataContext.SubmitChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
